package com.example.home_module;

import android.util.Log;

import com.example.common.field.DataActionEntity;
import com.example.common.mvvm.databus.LiveDataBus;
import com.example.common.mvvm.viewmodel.BaseViewModel;

import com.example.home_module.entity.VideoEntity;
import com.example.network_sdk.BaseEntity;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;

import io.reactivex.schedulers.Schedulers;
import retrofit2.Retrofit;

public class VideoViewModel extends BaseViewModel<VideoRespository> {
    @Override
    public void onResult(BaseEntity entity) {
        if (entity instanceof VideoEntity){
            VideoEntity videoEntity= (VideoEntity) entity;
            Log.i("videosize", "onResult: "+videoEntity.data.data.size());
            Map<String,Object> map=new HashMap<>();
            map.put("data",videoEntity.data.data);
            DataActionEntity entity1 = new DataActionEntity();
            entity1.data=map;
            entity1.action="dsy";
            getUiDataFunction().getUiData().postValue(entity1);

        }
    }

    @Override
    public void initData() {
            respository.getVideoData(0,10,0)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(this);


    }
}
